//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet.StandardAddIn.Statistics
{
    internal class WeibullDistribution : ContinuousDistribution
    {

        public WeibullDistribution(double alpha, double beta)
        {
            Alpha = alpha;
            Beta = beta;
        }

        public double Alpha{
            get;
            set;}

        public double Beta { get;
            set; }

        protected override SolverParameters GetSolverParameters(double probability)
        {
            throw new NotSupportedException();
        }


        public double Probability(double x)
        {
            if (x < 0)
                throw new ArgumentOutOfRangeException("x");
            return (Alpha/Math.Pow(Beta, Alpha))*Math.Pow(x, Alpha - 1)*Math.Exp(-Math.Pow(x/Beta, Alpha));
        }

        public override double CumulativeProbability(double x)
        {
            if (x < 0)
                throw new ArgumentOutOfRangeException("x");
            return 1 - Math.Exp(-Math.Pow(x/Beta, Alpha));
        }
    }
}